#include <bits/stdc++.h>
#define int long long 
using namespace std;

const int maxn = 1e6 + 5;
const int p = 1e9 + 7;
int dp[maxn]; // dp[i] 表示以 i 结尾的方案数
int prefix[maxn];
int n, k;


void solve(){
	cin >> n >> k;
	dp[0] = prefix[0] = 1; // 不要忘记 赋初值 
	for (int i=1;i<=n;i++) {
		if (i-k-1>0) { 
			dp[i] = prefix[i-k-1];			
		} else {
			dp[i] = 1;
		}
		prefix[i] = (prefix[i-1] + dp[i]) % p;
	}
	cout << prefix[n] << '\n';
}




signed main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
	return 0;
}
